package com.by.component.tencent.vod;

import com.by.component.tencent.TencentAccessProperties;
import com.tencentcloudapi.common.Credential;
import com.tencentcloudapi.common.profile.ClientProfile;
import com.tencentcloudapi.common.profile.HttpProfile;
import com.tencentcloudapi.vod.v20240718.VodClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import javax.annotation.Resource;

@Slf4j
@Configuration
public class TencentVodConfig {

    @Resource
    private TencentAccessProperties tencentAccessProperties;

    @Resource
    private TencentVodProperties tencentVodProperties;

    @Bean
    public VodClient initVodClient() {
        log.info("[TencentVodConfig][initVodClient] start");
        Credential cred = new Credential(tencentAccessProperties.getSecretId(), tencentAccessProperties.getSecretKey());
        HttpProfile httpProfile = new HttpProfile();
        httpProfile.setEndpoint("vod.tencentcloudapi.com");
        ClientProfile clientProfile = new ClientProfile();
        clientProfile.setHttpProfile(httpProfile);
        return new VodClient(cred, tencentVodProperties.getRegion(), clientProfile);
    }

}
